home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 009a / snpd0493.zip / CBTRAP.ASM < prev    next >
Assembly Source File  |  1993-04-05  |  1KB  |  64 lines

  1.         PAGE ,132
  2.  
  3. ;  Install a custom Interrupt 1b (Ctrl-Break exception) handler
  4. ;
  5. ;  Public domain by Bob Stout
  6. ;
  7. ;  Requires MASM 5.1 or later or equivalent
  8. ;
  9. ;  Assemble with:       MASM /Mx /z ...
  10. ;                       TASM /jMASM /mx /z ...
  11.  
  12. %       .MODEL  memodel,C               ;Add model support via command
  13.                                         ;line macros, e.g.
  14.                                         ;MASM /Dmemodel=LARGE
  15.  
  16.         .DATA?
  17. _origvec        dd      ?
  18.  
  19.         .DATA
  20.  
  21.         public  cbrcvd
  22.  
  23. cbrcvd  dw      0
  24.  
  25.         .CODE
  26.  
  27. ;
  28. ;  This is our actual ISR
  29. ;
  30. myint1b:
  31.         mov     ax,-1
  32.         mov     cbrcvd,ax
  33.         iret
  34.  
  35. ;
  36. ;  Call this to install  our ISR
  37. ;
  38. ins1b   PROC    USES AX BX DS ES
  39.         mov     ax,351bh                ;get old vector...
  40.         int     21h
  41.         mov     word PTR _origvec,bx
  42.         mov     word PTR _origvec+2,es  ;...and save it
  43.  
  44.         push    cs                      ;get myint1b segment in DS
  45.         pop     ds
  46.         mov     dx, OFFSET myint1b      ;install myint1b in int 1bh
  47.         mov     ax,251bh
  48.         int     21h
  49.         ret
  50. ins1b   ENDP
  51.  
  52. ;
  53. ;  Call this to uninstall our ISR
  54. ;
  55. redo1b  PROC    USES AX BX DS
  56.         mov     dx, word PTR _origvec   ;restore original vector
  57.         mov     ds, word PTR _origvec+2
  58.         mov     ax,251bh
  59.         int     21h
  60.         ret
  61. redo1b  ENDP
  62.  
  63.         end
  64.